/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
// pegdial.hpp - Base for the PegDial classes
//
// Author: Jim DeLisle
//
// Copyright (c) 1997-2000 Swell Software 
//              All Rights Reserved.
//
// Unauthorized redistribution of this source code, in whole or part,
// without the express written permission of Swell Software
// is strictly prohibited.
//
// Notes:
//
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/

#ifndef _PEGDIAL_HPP_
#define _PEGDIAL_HPP_


#define DS_ANCHORWIDTH          4
#define DS_THICKNEEDLEWIDTH     3


/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
class PegDial : public PegThing
{
    public:
        PegDial(const PegRect& Rect, PEGULONG Style);
        PegDial(PEGINT Left, PEGINT Top, PEGULONG Style);
        virtual ~PegDial();

        PEGINT GetAnchorColor() const { return mAnchorColorId; }
        PEGUINT GetAnchorWidth() const { return mAnchorWidth; }
        PEGINT GetCurAngle() const { return mCurAngle; }
        PEGLONG GetCurrentValue() const { return mCurValue; }

        PEGINT GetDialColor() const { return mDialColorId; }
        PEGINT GetMinAngle() const { return mMinAngle; }
        PEGLONG GetMinValue() const { return mMinValue; }
        PEGINT GetMaxAngle() const { return mMaxAngle; }
        PEGLONG GetMaxValue() const { return mMaxValue; }

        PEGINT GetNeedleColor() const { return mNeedleColorId; }
        PEGUINT GetNeedleLength() const { return mNeedleLen; }
        PEGLONG GetTicFreq() const { return mTicFreq; }
        PEGUINT GetTicLen() const { return mTicLen; }

        virtual PEGLONG IncrementValue(PEGLONG Value, PEGBOOL Redraw = TRUE);

        void SetAnchorColor(PEGINT ColorId)
        {
            mAnchorColorId = ColorId;
        }
        void SetAnchorWidth(PEGUINT Width)
        {
            mAnchorWidth = Width;
        }
        void SetDialColor(PEGINT ColorId)
        {
            mDialColorId = ColorId;
        }
        void SetNeedleColor(PEGINT ColorId)
        {
            mNeedleColorId = ColorId;
        }
        void SetNeedleLength(PEGUINT Len)
        {
            if(Len <= 100)
            {
                mNeedleLen = Len;
            }
        }
        void SetTicFreq(PEGLONG Freq)
        {
            mTicFreq = Freq;
        }
        void SetTicLen(PEGUINT Len)
        {
            if(Len <= 100)
            {
                mTicLen = Len;
            }
        }
        virtual void SetValue(PEGLONG Value, PEGBOOL Redraw = TRUE);
        

    protected:

        virtual void CalcClipAndDraw();
        virtual void CalcNeedlePos() = 0;
        virtual void CalcTicPos(PEGLONG Val, PegPoint& Pt1, PegPoint& Pt2);
        virtual void DrawAnchor();
        virtual void DrawDial();
        virtual void DrawNeedle();
        virtual void DrawTicMarks() = 0;
        virtual void EraseNeedle();
        virtual PEGINT ValToAngle(PEGLONG Val) = 0;

        PegRect mNeedlePos;

        PEGLONG mCurValue;
        PEGLONG mTicFreq;
        PEGLONG mMinValue;
        PEGLONG mMaxValue;

        PEGUINT mNeedleLen;
        PEGUINT mTicLen;
        PEGUINT mAnchorWidth;

        PEGINT mCurAngle;
        PEGINT mMinAngle;
        PEGINT mMaxAngle;

        PEGINT mNeedleColorId;
        PEGINT mDialColorId;
        PEGINT mAnchorColorId;

        PEGBOOL mValueSet;
};

#endif // _PEGDIAL_HPP_


